package com.asset.dispoal.evidenceconfig;

import com.asset.dispoal.evidenceconfig.api.BsEvidenceConfService;
import com.asset.dispoal.evidenceconfig.dto.request.BsEvidenceConfRequest;
import com.asset.dispoal.evidenceconfig.dto.response.BsEvidenceConfResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.controller.BaseController;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @author qr
 * @date 2021/10/21$
 */
@RestController
@Api(value = "证据打包配置管理", tags = "证据打包配置管理")
@RequestMapping("/bs/evidenceConf")
public class BsEvidenceConfController extends BaseController {

    @Autowired
    BsEvidenceConfService bsEvidenceConfService;

    @ApiOperation(value = "根据编码或名称查询证据包")
    @ApiImplicitParam(name = "bsEvidenceConfRequest", value = "证据请求对象")
    @PostMapping("/findEvidenceConf")
    private Result<PageVO<BsEvidenceConfResponse>> findEvidenceConf(@RequestBody(required = false) BsEvidenceConfRequest bsEvidenceConfRequest) {
        return Result.ok(bsEvidenceConfService.findEvidenceConf(bsEvidenceConfRequest));
    }

    @ApiOperation(value = "添加修改")
    @ApiImplicitParam(name = "bsEvidenceConfRequest", value = "证据请求对象")
    @PostMapping("/insertOrUpdate")
    private Result insertOrUpdate(@RequestBody BsEvidenceConfRequest bsEvidenceConfRequest) {
        bsEvidenceConfService.insertOrUpdate(bsEvidenceConfRequest);
        return Result.ok();
    }

    @ApiOperation(value = "删除")
    @ApiImplicitParam(name = "bsEvidenceConfRequest", value = "证据请求对象")
    @PostMapping("/del")
    private Result del(@RequestBody BsEvidenceConfRequest bsEvidenceConfRequest) {
        bsEvidenceConfService.del(bsEvidenceConfRequest);
        return Result.ok();
    }

    @ApiOperation(value = "根据批次查询下拉列表")
    @ApiImplicitParam(name = "batchId", value = "批次id")
    @GetMapping("/findListByBatchId")
    private Result findListByBatchId(String batchId) {
        return Result.ok(bsEvidenceConfService.findListByBatchId(batchId));
    }
}